//
//  MoreImageButton.m
//  BosidengIphone
//
//  Created by  on 12-2-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "MoreImageButton.h"

@implementation MoreImageButton

- (void)initSubViews {
    image = [UIImage imageNamed:@"More_Photo.png"];
    morePicMark = [[UIImageView alloc] initWithImage:image];
    [self addSubview:morePicMark];
    [morePicMark release];
    
    morePicture = [UIButton buttonWithType:UIButtonTypeCustom];
    [morePicture setTitle:@"" forState:UIControlStateNormal];
    [self addSubview:morePicture];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    CGRect frame = self.bounds;
    CGFloat imageWidth = image.size.width / 2.0;
    CGFloat imageHeight = image.size.height / 2.0;
    CGFloat x = (frame.size.width - imageWidth) / 2.0;
    CGFloat y = (frame.size.height - imageHeight) / 2.0;
    morePicMark.frame = CGRectMake(x, y, imageWidth, imageHeight);
    morePicture.frame = frame;
}

- (void)dealloc {
    [super dealloc];
}

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
    [morePicture addTarget:target action:action forControlEvents:controlEvents];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
